package config

import (
	"github.com/ethereum/go-ethereum/ethclient"
	"go-chain-data/global"
)

func NewEthRpcClient() (*ethclient.Client, error) {
	//rpcList := []string{
	//	"https://bsc-dataseed1.binance.org/",
	//	"https://bsc-dataseed2.binance.org/",
	//	"https://bsc-dataseed3.binance.org/",
	//	"https://bsc-dataseed4.binance.org/",
	//	"https://bsc-dataseed1.defibit.io/",
	//	"https://bsc-dataseed2.defibit.io/",
	//	"https://bsc-dataseed3.defibit.io/",
	//	"https://bsc-dataseed4.defibit.io/",
	//	"https://bsc-dataseed1.ninicoin.io/",
	//	"https://bsc-dataseed2.ninicoin.io/",
	//	"https://bsc-dataseed3.ninicoin.io/",
	//	"https://bsc-dataseed4.ninicoin.io/",
	//}
	//
	//// 随机数
	//index := rand.Intn(len(rpcList))
	//log.Printf("使用的RPC: %s", rpcList[index])
	client, err := ethclient.Dial(global.BlockChainConfig.RpcUrl)
	if err != nil {
		return nil, err
	}
	return client, nil
}
